package com.TeamJigsaw.DanteTrail.Models;

import java.util.Random;

import javax.swing.JOptionPane;

import com.TeamJigsaw.DanteTrail.Views.MainViewFrame;

public class OxenDeathEvent extends RandomEvent {

	private Random generator;
	
	private String eventMessage;
	
	private MainViewFrame mainView;
	
	public OxenDeathEvent (MainViewFrame mainView) {
		
		generator = new Random();
		eventMessage = null;
		this.mainView = mainView;
		
	}
	
	@Override
	public boolean performEvent(Party party) {
		int randNum = generator.nextInt(101);
		int pace = party.getPace();
		double multiply = 0.00;
		if (pace == 5){
			multiply = 1.20;
		}
		else if (pace == 10){
			multiply = 1.15;
		}
		else if (pace == 15){
			multiply = 1.10;
		}
		else if (pace == 20){
			multiply = 1.05;
		}

		double newRand = randNum * multiply;
		
		if (newRand > 99){
			Wagon tempWagon = party.getWagon();
			if (tempWagon.getOxenNo() == 0){
				JOptionPane.showMessageDialog(mainView, "All the hellhounds have died, game over...");
			}
			else {
				tempWagon.getOxen().remove(0);
			}
			eventMessage = "A hellhound has died...";
			return true;
		}

		return false;
	}

	@Override
	public String getMessage() {
		// TODO Auto-generated method stub
		return eventMessage;
	}

}
